<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./js/vue.js"></script>
    <title>嵌套组件</title>
    <style>
        
    </style>
</head>
<body>
    <div id="root">
        <!-- 
        -->
    </div>
</body>
<script>

    //第一步 创建组件
    const school = Vue.extend({
        template: `
            <div>
                <h1>学校名称:{{schoolName}}</h1>
                <h1>学校地址:{{address}}</h1>
                <button @click="showSchoolName">点我显示学校名称</button>
            </div>`,
        data() {
            return {
                schoolName: "尚硅谷",    // 学校名称
                address: "北京市海淀区西二旗"  // 学校地址
            }
        },
        methods: {
            showSchoolName() {
                console.log(this);
                alert(this.schoolName);
            }
        }
    });

    //第一步 创建组件
    const test = Vue.extend({
        template: `
            <div>
                <h1>你好啊尚硅谷</h1>
            </div>`
        
    })

    //第三步 使用组件
    const hello = Vue.extend({
        template: `
            <div>
                <h1>你好啊{{name}}</h1>
                <test></test>
            </div>`,
        data() {
            return {
                name: "张三"
            }
        },
        components: {
            test
        }
    })

    

    school.a = 100;
    // console.log(school === hello);
    console.log(school.a);
    console.log(hello.a);

    var vm = new Vue({
        el: '#root',
        // 第二步，注册组件(局部注册)
        components: {
            "school": school,
            "hello": hello
        }
    })
   
</script>
</html>